package com.hlkj.cartweb.controller;

import com.hlkj.pojo.common.TbBrand;
import com.hlkj.pojo.entity.PageResult;
import com.hlkj.cartweb.feign.TbBrandClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TbBrandController {
    @Autowired
    TbBrandClient tbBrandClient;

    @GetMapping("/admin/brand/findAll")
    public String hello() {
        //返回字符串
        return tbBrandClient.findAllBrands();
    }

    /**
     * 添加brand
     *
     * @param entity brand
     * @return result
     */
    @PostMapping("/admin/brand/addBrand")
    public String addBrand(@RequestBody TbBrand entity) {
        return tbBrandClient.addBrand(entity);
    }

    @PostMapping("/admin/brand/updateBrand")
    public String updateBrand(@RequestBody TbBrand brand) {
        return tbBrandClient.updateBrand(brand);
    }

    @GetMapping("/admin/brand/findById")
    public String findById(@RequestParam Long id) {
        return tbBrandClient.findById(id);
    }

    @PostMapping("/admin/brand/deleteByIds")
    public String deleteByIds(@RequestParam Long[] ids) {
        return tbBrandClient.deleteByIds(ids);
    }

    @GetMapping("/admin/brand/findPage")
    public String findPage(@RequestParam int page, @RequestParam int rows) {
        return tbBrandClient.findPage(page, rows);
    }

    @PostMapping("/admin/brand/search")
    public String search(@RequestParam int page, @RequestParam int rows, @RequestBody TbBrand brand) {
        return tbBrandClient.findPage(brand, page, rows);
    }
}
